package com.budwk.app.sqfw.controllers.admin;

import com.budwk.app.sqfw.dto.RiverChiefAssistantControllerDTO;
import com.budwk.app.sqfw.services.RiverChiefAssistantService;
import com.budwk.app.sqfwDoc.vo.RiverChiefAssistantThirdRiverVO;
import com.budwk.starter.common.openapi.annotation.ApiDefinition;
import com.budwk.starter.common.openapi.annotation.ApiOperation;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import com.budwk.starter.security.utils.SecurityUtil;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;

import java.util.List;

/**
 * @author ZY.Wang
 * @since 2024/6/12
 */
@IocBean
@At("platform/assistance/riverChiefAssistant")
@ApiDefinition(tag = "河长助手")
@Slf4j
public class RiverChiefAssistantController {

    @Inject
    private RiverChiefAssistantService riverChiefAssistantService;

    @At
    @Ok("json")
    @GET
    @ApiOperation(name = "查询河流数据")
    @SLog(tag = "录入河长助手检查数据", value = "${args[0]}")
    public Result<?> listRiver(@Param("riverName") String riverName) {
        List<RiverChiefAssistantThirdRiverVO> riverList = riverChiefAssistantService.listRiver(riverName);
        return Result.success(riverList);
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "录入河长助手检查数据")
    @SLog(tag = "录入河长助手检查数据", value = "${args[0]}")
    public Result<?> insertRiverChiefAssistant(@Param("..") RiverChiefAssistantControllerDTO insertDTO) {
        String userId = SecurityUtil.getUserId();
        riverChiefAssistantService.insert(userId, insertDTO);
        return Result.success();
    }
}
